package com.aaa.java15;

import java.io.*;

/**
 * @author ：Teacher陈（86521760@qq.com）
 * @date ：Created in 2022/7/19 10:59
 * @description：
 * @modified By：
 * @version:
 */
public class IoTest {
    public static void main(String[] args) throws IOException {
        //获取文件对象
        File file = new File("D:\\qy156\\aaa.txt");
      /*  //获取文件输入流(字节流)
        FileInputStream fileInputStream = new FileInputStream(file);
        //一次读取4字节
        byte [] bytes = new byte[4];
        int  count=0;
       *//*   int count = fileInputStream.read(bytes);
      System.out.println("读取的内容"+new String(bytes)+"||count:"+count);
         count = fileInputStream.read(bytes);
        System.out.println("读取的内容"+new String(bytes)+"||count:"+count);
         count = fileInputStream.read(bytes);
        System.out.println("读取的内容"+new String(bytes)+"||count:"+count);
         count = fileInputStream.read(bytes);
        System.out.println("读取的内容"+new String(bytes)+"||count:"+count);
        //如果没有内容可以读取，count为-1
         count = fileInputStream.read(bytes);
        System.out.println("读取的内容"+new String(bytes)+"||count:"+count);*//*

        *//**
         *   * @param  bytes
         *      *         The bytes to be decoded into characters
         *      *
         *      * @param  offset
         *      *         The index of the first byte to decode
         *      *
         *      * @param  length
         *      *         The number of bytes to decode
         *//*
        while ((count = fileInputStream.read(bytes))!=-1){
           System.out.println("读取的内容"+new String(bytes,0,count)+"|| count:"+count);
       }*/

        System.out.println("===============================================");
        Reader reader = new FileReader(file);
        char [] chars = new char[8];
        int count=0;
        while ((count=reader.read(chars))!=-1){
            System.out.println("读取的内容"+new String(chars,0,count)+"|| count:"+count);
        }
    }
}
